import request from '@/hooks/request'

const Api = {
  getWechartScriptList: '/platform/wechatScript/getWechatScriptList', // 话术列表
  editWechartScriptContent: '/platform/WechartScript/editWechartScriptContent', // 修改话术
  wechartScriptPushArriveRobots: '/platform/wechatScript/wechatScriptPushArriveRobots', // 推送配置
  getWechartScriptTemplate: '/platform/WechartScript/getWechartScriptTemplate', // 话术模板
  editWechartScriptTemplate: '/platform/WechartScript/editWechartScriptTemplate', // 修改话术模板
  getFishScriptList: '/platform/fishScript/getFishScriptList',
  fishScriptPushArriveRobots: '/platform/fishScript/fishScriptPushArriveRobots',
  scriptGroupList: 'platform/common/scriptGroupList', // 获取分类
}

export const ScriptGroupList = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('channel', parameter.channel)
  return request({
    method: 'post',
    url: Api.scriptGroupList,
    data: formData,
  })
}

export const getWechartScriptList = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('robotId', parameter.robotId)
  if (parameter.groupNum) {
    formData.append('groupNum', parameter.groupNum)
  }

  return request({
    method: 'post',
    url: Api.getWechartScriptList,
    data: formData,
  })
}

export const getFishScriptList = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('robotId', parameter.robotId)
  if (parameter.groupNum) {
    formData.append('groupNum', parameter.groupNum)
  }
  return request({
    method: 'post',
    url: Api.getFishScriptList,
    data: formData,
  })
}

export const editWechartScriptContent = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editWechartScriptContent,
    data: parameter,
  })
}

export const wechartScriptPushArriveRobots = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.wechartScriptPushArriveRobots,
    data: parameter,
  })
}

export const fishScriptPushArriveRobots = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.fishScriptPushArriveRobots,
    data: parameter,
  })
}

export const getWechartScriptTemplate = () => {
  return request({
    method: 'post',
    url: Api.getWechartScriptTemplate,
  })
}

export const editWechartScriptTemplate = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editWechartScriptTemplate,
    data: parameter,
  })
}
